/*
 * author      : 吴中勤 
 * date        : 2018/9/17
 * description : TODO
 */

package com.deepexi.adapter.mq;

import com.deepexi.mq.api.IMQService;
import com.deepexi.mq.api.MQFactory;
import com.deepexi.mq.domain.MessageRegistryVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqRecieverBean {
    private static final Logger logger = LoggerFactory.getLogger(EventProcessorImpl.class);

    @Value("${mq.namesrvAddr}")
    private String namesrvAddr;

    @Value("${spring.application.name}")
    private String groupName;

    @Bean
    public IMQService mqService() {

        logger.info("mq Addr={}, groupName={}", namesrvAddr, groupName);

        MessageRegistryVo vo = new MessageRegistryVo();
        vo.setBrokerList(namesrvAddr);
        vo.setType("rocket");
        vo.setGroupName(groupName);
        vo.setInstanceName("DEFAULT");

        return MQFactory.createMQ(vo);
    }

}
